<%@page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<jsp:useBean id="user" class="model.User" scope="session"></jsp:useBean>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Air Transport - Passengers on Flight</title>
</head>
<body>

<c:if test="${not user.accessed}">
	<c:redirect url="index.html"></c:redirect>
</c:if>

<c:if test="${not user.loggedIn}">
	<c:redirect url="index.html"></c:redirect>
</c:if>

<c:if test="${empty flight}">
	<c:redirect url="main.html"></c:redirect>
</c:if>

<h2><u>Air Transport Service - Passengers on Flight</u></h2>

<jsp:include page="header.jsp"></jsp:include>

<table border="1">
	<tr bgcolor="lightgrey">
		<td style="BACKGROUND-COLOR: #b7d0ec;">Flight ID:</td>
		<td style="BACKGROUND-COLOR: #e7cfad;">${flight.id}</td>
	</tr>
	<tr bgcolor="lightgrey">
		<td style="BACKGROUND-COLOR: #b7d0ec;">Departure Time:</td>
		<td style="BACKGROUND-COLOR: #e7cfad;">${flight.departureTimeFormated}</td>
	</tr>
	<tr bgcolor="lightgrey">
		<td style="BACKGROUND-COLOR: #b7d0ec;">Source:</td>
		<td style="BACKGROUND-COLOR: #e7cfad;">${flight.source}</td>
	</tr>
	<tr bgcolor="lightgrey">
		<td style="BACKGROUND-COLOR: #b7d0ec;">Destination:</td>
		<td style="BACKGROUND-COLOR: #e7cfad;">${flight.destination}</td>
	</tr>
</table>

<hr />
<c:choose>
	<c:when test="${not empty passengers}">
		<table border="1">
			<tr bgcolor="lightgrey">
				<th>Passenger</th>
				<th>Reservation</th>
			</tr>

			<c:forEach var="passenger" items="${passengers}">
				<tr>
					<td><a href='passenger.html?jmbg=${passenger.jmbg }'>${passenger}</a></td>
					<c:choose>
						<c:when test="${not flight.expired}">
							<form method="get" action="cancellation.html">
								<td align="center">
									<input type="hidden" name="jmbg" value="${passenger.jmbg }" /> 
									<input type="hidden" name="flightid" value="${flight.id }" /> 
									<input type="submit" value="Cancel" />
								</td>
							</form>
						</c:when>
						<c:otherwise>
							<td>Cancel Exp.</td>
						</c:otherwise>
					</c:choose>
				</tr>
			</c:forEach>



		</table>
	</c:when>
	<c:otherwise>
		Nema prijavljenih putnika!<br />
	</c:otherwise>
</c:choose>

<hr />
<p><a href="main.html">Main Page - Flight List</a></p>
<p><a href="logout.html">Logout</a></p>

<jsp:include page="footer.jsp"></jsp:include>

</body>
</html>